﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;
using DevExpress.XtraGrid.Views.Grid;

namespace QuanLyKho.PhongThanhPham
{
    public partial class DanhSachChiaSP : UserControl
    {
        public DanhSachChiaSP()
        {
            InitializeComponent();
            LoadData();
        }

        public void LoadData()
        {
            var table = DataAll.SelectAll("PhieuChiaHang", "*", "");
            gridChiaHang.DataSource = table;
            SetPropertiesGrid();
        }

        public void SetPropertiesGrid()
        {
            //gvChiaHang.BestFitColumns();
            gvChiaHang.OptionsBehavior.Editable = false;
            gvChiaHang.FocusRectStyle = DrawFocusRectStyle.RowFullFocus;
            gvChiaHang.OptionsSelection.EnableAppearanceFocusedCell = false;
            gvChiaHang.OptionsSelection.MultiSelect = true;
            gvChiaHang.OptionsView.ShowGroupPanel = false;
            gvChiaHang.OptionsView.ColumnAutoWidth = true;
            gvChiaHang.OptionsView.ShowFooter = true;
            gvChiaHang.OptionsFind.AlwaysVisible = true;
        }

        private void bntChiaSanPham_Click(object sender, EventArgs e)
        {
            //Chiasanpham.xem = true;
            var themsanpham = new Chiasanpham();
            themsanpham.ShowDialog();
            LoadData();
            //Chiasanpham.xem = false;
        }

        private void gvChiaHang_DoubleClick(object sender, EventArgs e)
        {
            if (gvChiaHang.FocusedRowHandle >= 0)
            {
                Chiasanpham.MaID = gvChiaHang.GetDataRow(gvChiaHang.FocusedRowHandle)["ID"].ToString();
                var themsp = new Chiasanpham();
                themsp.ShowDialog();
                LoadData();
                Chiasanpham.MaID = "0";
            }
        }
    }
}
